home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SATAN11.ZIP / BIN / SHOWMOUN.SAT < prev    next >
Encoding:
Text File  |  1995-04-11  |  2.7 KB  |  111 lines

  1. #!/usr/local/bin/perl5
  2. #
  3. # Find out some stuff about NFS using showmount: world-wide exports,
  4. # boot clients.  Should not bother to do this when rpc.rip fails.
  5. #
  6.  
  7. # require these packages:
  8. $running_under_satan = 1;
  9. require "config/paths.pl";
  10. require "perl/misc.pl";
  11. require "perl/fix_hostname.pl";
  12.  
  13. if ($#ARGV != 0) {
  14.         print "Usage $0 target\n";
  15.         exit(1);
  16.         }
  17.  
  18. $target = $ARGV[0];
  19. ($service = $0) =~ s@^.*/([^\/\.]*)\..*$@$1@;
  20.  
  21. #
  22. # we don't make value judgements here
  23. #
  24.  
  25. $severity = "x";
  26. $service_output = "";
  27.  
  28. # Showmount -e tells us who can mount what from this server.
  29.  
  30. open(SM, "$SHOWMOUNT -e $target|");
  31.  
  32. while (<SM>) {
  33.     chop;
  34.     next unless /^(\S+)\s+(\S+)\s*$/;
  35.     $files = $1;
  36.     @hosts = split(",", $2);
  37.     for $host (@hosts) {
  38.         $Host = $host;
  39.         $host =~ tr/A-Z/a-z/;
  40.         if ($host eq "\(everyone\)" || $Host eq "Everyone") {
  41.             next if $untrusted_host;
  42.             $status="a";
  43.             $trustee="$files\@$target";
  44.             $trusted="root\@ANY";
  45.             $service_output="unrestricted NFS export";
  46.             $text="exports $files to everyone";
  47.             }
  48.         else {
  49.             $fqdn = &fix_hostname($host ,$target);
  50.             # if the host doesn't really exist, it could
  51.             # be a netgroup or something... try to complete
  52.             # hostname if not FQDN, etc., then try to resolve.
  53.             # If everything fails, just output what we can:
  54.             if ($fqdn eq "") {
  55.                 $status="u";
  56.                 $trustee="$files\@$target";
  57.                 $trusted="root\@$host";
  58.                 $service_output="$target $host";
  59.                 $text="exports $files to $host, but we can't verify that $host exists";
  60.                 }
  61.             else {
  62.                 $host = $fqdn;
  63.                 $status="a";
  64.                 $trustee="$files\@$target";
  65.                 $trusted="root\@$host";
  66.                 $service_output="$target $host";
  67.                 $text="exports $files to $host";
  68.                 }
  69.             }
  70.         &satan_print();
  71.         $print_flag = 1;
  72.         }
  73.     }
  74.  
  75. # Showmount -a tells what systems actually mount from this server.
  76.  
  77. open(SM, "$SHOWMOUNT -a $target|");
  78.  
  79. while (<SM>) {
  80.     chop;
  81.     next unless /(\S+):(\S+)/;
  82.     ($host = $1) =~ tr/A-Z/a-z/;
  83.     $path = $2;
  84.     $fqdn = &fix_hostname($host ,$target);
  85.     # If everything fails, just output what we can:
  86.     if ($fqdn eq "") {
  87.         $status="u";
  88.         $trustee="$path\@$target";
  89.         $trusted="root\@$host";
  90.         $service_output="$target $host";
  91.         $text="$host mounts $path from $target, but we can't verify that $host exists";
  92.     } else {
  93.         $host = $fqdn;
  94.         $status="a";
  95.         $trustee="$path\@$target";
  96.         $trusted="root\@$host";
  97.         $service_output="$target $host";
  98.         $text="$host mounts $path from $target";
  99.     }
  100.     &satan_print();
  101.     $print_flag = 1;
  102. }
  103.  
  104. # print something out if nothing has happened so far...
  105. if (!$print_flag) {
  106.     $status="a";
  107.     $severity="";
  108.     $text="Not running showmount or other error";
  109.     &satan_print();
  110. }
  111.